﻿using Mt.Site.Core.ContentManagement.Entities;
using Mt.Site.Core.ContentManagement.Values;
using Mt.Site.Core.Navigations.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Mt.Site.Core.ContentManagement
{
    public interface IContent2FrontendManager
    {
        #region 泛型

        /// <summary>
        /// 详情（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="id">数据id</param>
        /// <returns></returns>
        Task<T> GetContentByIdAsync<T>(long id, long menuId, long relateId) where T : new();
        Task<T> GetContentByIdAsync<T>(long id, long menuId, Guid? relateId) where T : new();

        /// <summary>
        /// 详情预览（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="id">数据id</param>
        /// <returns></returns>
        Task<T> GetContentByIdPreaViewAsync<T>(Guid id, long menuId, Guid? relateId) where T : new();

        /// <summary>
        /// 分页（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="queryMethod"></param>
        /// <param name="skipCount"></param>
        /// <param name="getCount"></param>
        /// <returns></returns>
        Task<PagedContent<T>> GetContentListByPagedAsync<T>(
            Func<IQueryable<Content2>, IQueryable<Content2>> queryMethod,
            List<long> menuIdList,
            Guid? relateId,
            long? startTime,
            long? endTime,
            int skipCount,
            int getCount) where T : new();


        /// <summary>
        /// 不分页（附件自行加载）
        /// </summary>
        /// <typeparam name="T">Dto类型</typeparam>
        /// <param name="queryMethod"></param>
        /// <returns></returns>
        Task<List<T>> GetAllContentAsync<T>(
            Func<IQueryable<Content2>, IQueryable<Content2>> queryMethod, List<long> menuIdList, Guid? relateId, int maxCount, 
            bool shouldHasPic, List<string> aliasList, bool IsHomeRecommend) where T : new();

        #endregion

        Task<Dictionary<string, object>> GetAsync(long id, long menuId, Guid? relateId);


        /// <summary>
        /// 浏览量+1
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<int> UpdatePv(long id);

        /// <summary>
        /// 获取上一页下一页（返回 id）
        /// </summary>
        /// <param name="menuId"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        Task<PreAndNextItemId> GetPreAndNextLink(long menuId, Guid? relateId, Guid id);

        Task<Dictionary<Guid, List<ContentMenuDto>>> GetMenuIdsByContentIdListAsync(List<long> menuIdList, List<Guid> idList);
    }
}
